package com.example.myworkc;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;

public class MyService1 extends Service {
    private MediaPlayer mediaPlayer;
    private int[] musics = {R.raw.music1};

    public MyService1() {
        Log.d("service", "MyService1");
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public IBinder onBind(Intent intent) {
        return new MyBinder();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        return super.onUnbind(intent);
    }

    @Override
    public void onDestroy() {
            mediaPlayer.stop();
            mediaPlayer.release();
        super.onDestroy();

    }

    protected class MyBinder extends Binder {
        public void play() {
            MediaPlayer mediaPlayer;
            mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.music1);
            mediaPlayer.start();
        }
    }
}